﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="EWebsite.Admin.Category2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .style1
        {
            text-align: center;
        }
        .style2
        {
            width: 140px;
        }
        .style3
        {
            width: 255px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <span class="page-title">Danh mục sản phẩm</span>
    <div id="left-col">
        <asp:GridView ID="grvCategories" runat="server" Width="100%" 
            EnableModelValidation="True" AutoGenerateColumns="False" 
            onrowdeleting="grvCategories_RowDeleting" 
        onrowcancelingedit="grvCategories_RowCancelingEdit" 
        onrowediting="grvCategories_RowEditing" 
        onrowupdating="grvCategories_RowUpdating" AllowPaging="True" 
            onpageindexchanging="grvCategories_PageIndexChanging">
            <Columns>
                <asp:TemplateField HeaderText="CatID" Visible="False">
                    <EditItemTemplate>
                        <asp:Label ID="lblCatID" runat="server" Text='<%# Bind("CatID") %>'></asp:Label>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblCatID" runat="server" Text='<%# Bind("CatID") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Name">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtCatName" runat="server" Text='<%# Bind("CatName") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblName" runat="server" Text='<%# Bind("CatName") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Parent">
                    <EditItemTemplate>
                        <asp:DropDownList ID="drpParentCatID" runat="server" 
                            DataSource="<%# getCategoriesTable() %>" DataTextField="CatName" 
                            DataValueField="CatID" SelectedValue='<%# Bind("ParentCatID") %>' 
                            Height="30px" Width="200px">
                        </asp:DropDownList>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:DropDownList ID="drpParentCatID" runat="server" 
                            DataSource="<%# getCategoriesTable() %>" DataTextField="CatName" 
                            DataValueField="CatID" Enabled="False" Height="30px" 
                            SelectedValue='<%# Bind("ParentCatID") %>' Width="200px">
                        </asp:DropDownList>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Delete Category" ShowHeader="False">
                    <ItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                            CommandName="Delete" Text="Delete"></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:CommandField ShowEditButton="True" HeaderText="Edit Category" />
            </Columns>
        </asp:GridView>
    </div><!--#left-col-->
    <div id="right-col">
        <div class="catTree">
            <h4>Category Tree</h4>
            <% temp = TblCategories; 
                this.printCategoryTree(ref temp, 0, 0); 
            %>
        </div>
        <table>
            <tr>
                <td class="style1" colspan="2">
                    <strong>New Category</strong></td>
            </tr>
            <tr>
                <td class="style2">
                    Name</td>
                <td class="style3">
                    <asp:TextBox ID="txtCatName" runat="server" Width="159px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style2">
                    Parent category</td>
                <td class="style3">
        <select id="categoriesTree" name="categoriesTree">
            <option value="-1">--No parent--</option>
            <% for (int i = 0; i < TblCategories.Rows.Count; i++) { %>
            <option value="<%= TblCategories.Rows[i]["CatID"] %>"><%= TblCategories.Rows[i]["CatName"] %></option>
            <% } %>
        </select></td>
            </tr>
            <tr>
                <td class="style2">
                    &nbsp;</td>
                <td class="style3">
        <asp:Button ID="btnAdd" runat="server" Text="Add" onclick="btnAdd_Click" />
                </td>
            </tr>
        </table>
    </div><!--right-col-->
    </asp:Content>
